import type { App } from "vue";
import { reportInfoApi } from "@/xz-fn";
function reportInfo(event_id: unknown) {
  if(typeof event_id === 'function'){
    event_id = event_id()
  }
  if(typeof event_id === 'number'){
    reportInfoApi(event_id)
  }
}
export const initReportDirective = (app: App) => {
  // 显示上报
  app.directive('show-report', {
    mounted(el, binding) {
      reportInfo(binding.value)
    },
    updated(el, binding){
      reportInfo(binding.value)
    }
  });

  // 点击上报
  app.directive('report', {
    mounted(el, binding) {
      el.addEventListener('click', () => {
        reportInfo(binding.value)
      });
    }
  });
};